<template>
    <div>
        <Card>
            <p slot="title">信息审核开关</p>
            <Form ref="form2" :model="model"  :label-width="100">
                <FormItem label="" prop="switch">
                    <i-switch v-model="model.switch" @on-change="change" size='large' v-if="checkPermission('112827')">
                        <span slot="open">开启</span>
                        <span slot="close">关闭</span>
                    </i-switch>
                    <span style="padding-left:5px;color:#ff9900">{{ model.switch ? "已开启" : "已关闭" }}</span>
                    </br>
                    <span style="padding-top:5px;color:red;font-size:15px;">重要提示：</span></br>
                    <span style="padding-top:5px;color:red;font-size:15px;">1、审核开关默认开启！</span></br>
                    <span style="padding-top:5px;color:red;font-size:15px;">2、审核开关只涉及到服务信息审核和需求信息审核。企业/服务机构注册信息需要管理员审核！</span></br>
                    <span style="padding-top:5px;color:red;font-size:15px;">3、开启后，服务信息和需求信息需要管理员审核通过才能发布。关闭后，服务信息和需求信息，自动审核通过并发布！</span>
                </FormItem>
            </Form>
        </Card>
    </div>
</template>

<script>
import parent from "../Parent";
    export default {
    extends:parent, 
    data () {
        return {
            model: {
                switch: true
            }
        }  
    },
    methods: {
        change (status) {
            this.model.switch = !status;
            this.api.post("free_value/set", { 
                keyvalues: {
                    "check.open_check": status ? "1" : "0"
                }
            }, res => {
                this.model.switch = status;
            });
        }
    },
    created() {
        this.api.post("free_value/get", {key : "check" }, res => {
            if(res.data.open_check != null){
                this.model.switch = res.data.open_check.value == "1";
            }
        });
    }
}  
</script>